home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Term / Extras / Rexx / Login-UXA.term < prev    next >
Text File  |  1994-07-13  |  3KB  |  99 lines

  1. /*----------------------------------------------------------------------*\
  2. Auto login to uxa through mosberg using Term 3.4
  3. by Nicolas Dade, December 1993, $VER: 1.02
  4.  
  5. throughout I refer to the terminal server as being mosberg, but it
  6. can be any of the many that are in use---term, ruger, beretta,...
  7.  
  8. The script takes an optional parameter, the name of a message
  9. port to which to send a message once the login is complete. This
  10. is for use by scripts that need to know then the login is over
  11. and they can proceed.
  12.  
  13. for example, specifying the Startup/Login macro in term to be
  14. \a rexx:Login-Uxa.term autodownload.login.finished
  15. will make the login script send a message to a port called
  16. "autodownload.login.finished" when it is finished.
  17.  
  18. \*----------------------------------------------------------------------*/
  19.  
  20.  PARSE ARG portname .
  21.  
  22.  RESETSCREEN
  23.  
  24. /* get mosberg to wakeup by sending CR until it prompts for our username */
  25.  TIMEOUT 'SEC 2'
  26.  woken='no'
  27.  DO i = 1 TO 10 WHILE woken='no'
  28.    SEND '\r'
  29.    WAIT '"username:"'
  30.    IF rc=0 THEN woken='yes'
  31.  END
  32.  IF woken~='yes' THEN DO
  33.    showerror("Couldn't get terminal server to respond.")
  34.    finish(10)
  35.  END
  36.  
  37. /* login to mosberg using our ph alias and password */
  38.  SEND 'nicolas-dade\r'
  39.  TIMEOUT 'SEC 10'
  40.  IF waitrc('password:',"Terminal server never asked for 'Password' after asking for 'Username'") THEN finish(10)
  41.  SEND 'NOECHO myphpassword\r'
  42. /* put mosberg in no-translation terminal mode */
  43.  IF waitrc('>',"Terminal server never gave a prompt after login") THEN finish(10)
  44.  SEND 'term download\r'
  45. /* connect from mosberg to uxa */
  46.  IF waitrc('>',"Terminal server never gave a prompt after setting term to download") THEN finish(10)
  47.  SEND 'uxa\r'
  48.  
  49. /* login to uxa using uxa login and password */
  50.  IF waitrc('login:',"uxa never asked for 'login', or uxa never responded") THEN finish(10)
  51.  SEND 'n-dade\r'
  52.  IF waitrc('password:',"uxa never asked for 'password'") THEN finish(10)
  53.  SEND 'NOECHO myuxapassword\r'
  54. /* keep sending CR until the first shell prompt appears */
  55.  atshell='no'
  56.  timeout sec 2
  57.  DO i = 1 TO 10 WHILE atshell='no'
  58.    SEND '\r'
  59.    WAIT '"uxa 1>"'
  60.    IF rc=0 THEN atshell='yes'
  61.  END
  62.  IF atshell~='yes' THEN DO
  63.    showerror("Couldn't get uxa to give first shell prompt.")
  64.    finish(10)
  65.  END
  66.  
  67. /* exit, things went ok */
  68.  ACTIVATE
  69.  finish(0)
  70.  
  71. /*--------------------------------------*/
  72.  
  73. waitrc: /* (waitstring, errorstring) */
  74.  PARSE ARG waitstring,errorstring
  75.  TIMEOUT 'SEC 30'
  76.  WAIT '"'waitstring'"'
  77.  IF rc=0 THEN DO
  78.    RETURN 0
  79.  END
  80.  ELSE DO
  81.    showerror(errorstring)
  82.    return 1
  83.  END
  84.  
  85. showerror: /* (errorstring) */
  86.  PARSE ARG errorstring
  87.  IF portname='' THEN
  88.    REQUESTNOTIFY 'TITLE "AutoLogin Aborting" PROMPT "'errorstring'"'
  89.  ELSE
  90.    say 'AutoLogin Aborting: 'errorstring
  91.  RETURN 0
  92.  
  93. finish: /* (return code) */
  94.  PARSE ARG returncode .
  95.  IF portname~='' THEN
  96.    IF show('ports',portname) THEN
  97.      INTERPRET "ADDRESS '"portname"' returncode" /* send message to waiting controling arexx script */
  98.  EXIT returncode
  99.